//
// Created by postgres on 4/19/17.
//
#include "../include/03StackQueue/stack.h"
typedef int ElemType;/* ElemType类型根据实际情况而定，这里假设为int */
Status InitSeqStack(SeqStackNode *s){
    (*s).top=0;
}
Status GetTop(SeqStackNode s,ElemType *e){
    if(s.top<=0)		/*在取栈顶元素之前，判断栈是否为空*/
    {
        printf("栈已经空!\n");
        return 0;
    }
    *e=s.data[s.top-1];
    return OK;
}
Status PushStack(SeqStackNode *s,ElemType e){
    if(s->top>=SeqStackMAXSIZE)		/*在取栈顶元素之前，判断栈是否为空*/
    {
        printf("stack had full!\n");
        return 0;
    }
    s->data[s->top]=e;
    s->top++;
    return OK;
}
Status PopStack(SeqStackNode *s,ElemType *e){
    if(s->top<=0)		/*在取栈顶元素之前，判断栈是否为空*/
    {
        printf("栈已经空!\n");
        return 0;
    }
    *e=s->data[s->top-1];
    s->top--;
    return OK;
}
Status ClearStack(SeqStackNode *s){
    s->top=0;
    return OK;
}
Status StackLength(SeqStackNode s)
/*求栈的长度，即栈中元素个数，栈顶指针的值就等于栈中元素的个数*/
{
    return s.top;
}
void SeqStack_Test(){
    SeqStackNode s;
    InitSeqStack(&s);
    int e;
    PushStack(&s,8192);
    PushStack(&s,8191);
    PushStack(&s,8190);
    PushStack(&s,8189);
    PopStack(&s, &e);
    PopStack(&s, &e);
    GetTop(s,&e);
}
